#include "../include/core/Transaction.h"
#include <utility>

namespace MiniBanking
{

    Transaction::Transaction(std::string id, TransactionType type, double amount,
                             std::chrono::system_clock::time_point timestamp,
                             std::string sourceID, std::string destID, std::string note)
        : transactionID_(std::move(id)),
          type_(type),
          amount_(amount),
          timestamp_(timestamp),
          sourceAccountID_(std::move(sourceID)),
          destinationAccountID_(std::move(destID)),
          note_(std::move(note))
    {
    }

    const std::string &Transaction::getID() const
    {
        return transactionID_;
    }

    TransactionType Transaction::getType() const
    {
        return type_;
    }

    double Transaction::getAmount() const
    {
        return amount_;
    }

    std::chrono::system_clock::time_point Transaction::getTimestamp() const
    {
        return timestamp_;
    }

    const std::string &Transaction::getSourceAccountID() const
    {
        return sourceAccountID_;
    }

    const std::string &Transaction::getDestinationAccountID() const
    {
        return destinationAccountID_;
    }

    const std::string &Transaction::getNote() const
    {
        return note_;
    }

    bool Transaction::operator<(const Transaction &other) const
    {
        return timestamp_ < other.timestamp_;
    }

    std::string transactionTypeToString(TransactionType type)
    {
        switch (type)
        {
        case TransactionType::DEPOSIT:
            return "Deposit";
        case TransactionType::WITHDRAW:
            return "Withdraw";
        case TransactionType::TRANSFER:
            return "Transfer";
        default:
            return "Unknown";
        }
    }

}
